export function formatTime(timestamp) {
  const now = new Date();
  const inputTime = new Date(timestamp);
  const diff = now - inputTime;

  // 转换为秒、分钟、小时、天、月
  const seconds = Math.floor(diff / 1000);
  const minutes = Math.floor(seconds / 60);
  const hours = Math.floor(minutes / 60);
  const days = Math.floor(hours / 24);
  const months = Math.floor(days / 30);

  if (minutes < 1) {
    return "1分钟";
  } else if (hours < 1) {
    return `${minutes}分钟`;
  } else if (days < 1) {
    return `${hours}小时`;
  } else if (days < 30) {
    return `${days}天`;
  } else if (months < 3) {
    return `${months}月`;
  } else {
    return null;
  }
}

export const goToHome = ()=>{
	uni.showModal({
		title:"提示",
		content:"页面内容有误将返回首页",
		showCancel:false,
		success(res) {
			if(res.confirm){
				uni.reLaunch({
					url:"/pages/index/index"
				})
			}
		}
	})
}